<!DOCTYPE html>
<#assign secSelect = JspTaglibs["http://www.casic304.cn/secSelect"] />
<#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<html>
<head>
    <meta charset="utf-8">
    <title>质量体系审核员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .qbdms-TBinformation{margin-left: 0;font-size: 15px}
        .qbdms-TBinformationText{margin-left: 145px;}
    </style>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
    <div class="qbdms-backDiv">
        <div class="layui-table-view-body" style="padding: 0 24px 24px;">
            <div class="qbdms-formTitle" style="border-bottom: 1px solid #E5F0FF">质量体系审核员 <i class="qbdms-returnOn closeWindow">返回</i></div>
        <form class="layui-form treeFormPreview" requrl="${ctx}/qbdms/wQbdTeamPeople/get" lay-filter="wQbdTeamPeopleDataForm" >
            <@fillDept.dept id="tbxx"/>
            <div class="layui-row">
                <div style="width: 40%">
                    <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@secSelect.sec_select data_src=1 required=true name="secret"/>
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="姓名">姓名<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="name" placeholder="请输入" autocomplete="off"
                               class="layui-input  textInput" maxlength="20" lay-verify="required"
                               lay-reqtext="姓名是必填项" fieldname="name">
                    </div>
                </div>
                <div style="width: 40%">
                    <label class="layui-form-label qbdms-label" title="性别">性别<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="sex" reqtext="性别是必填项" verify="required" nodeKey="zjxb" />
                    </div>
                </div>

                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="民族">民族<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="minzu" search=true verify="required" reqtext="民族是必填项" nodeKey="mz" />
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="籍贯">籍贯</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="jiguan" placeholder="请输入" autocomplete="off"
                               class="layui-input  textInput" maxlength="40" >
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="工作单位">工作单位<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="works" placeholder="请输入" autocomplete="off" readonly="readonly"
                               class="layui-input  textInput" lay-verify="required" lay-reqtext="工作单位是必填项" maxlength="50" >
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="身份证号码">身份证号码<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="idcode" placeholder="请输入" autocomplete="off" lay-verify="identity"
                               lay-verify="required" class="layui-input textInput" lay-reqtext="身份证号码是必填项" maxlength="18" fieldname="idcode">
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="出生日期">出生日期</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="birthday" placeholder="自动计算" readonly="readonly"
                               autocomplete="off" class="layui-input time-init isReadonlyInput"
                               maxlength="50" >
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="座机">座机</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="phone" placeholder="请输入" lay-verify="servicePhone"
                               autocomplete="off" class="layui-input  textInput" maxlength="20" >
                    </div>
                </div>

                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="联系方式">联系方式<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="contactinformation" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput"
                               lay-verify="required|phoneNum" maxlength="20" lay-reqtext="联系方式是必填项"  fieldname="contactinformation">
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="人员类别">人员类别<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="peopletype" filter="ry" verify="required" reqtext="人员类别是必填项" search=true nodeKey="rylb" />
                    </div>
                </div>
                <div style="width: 50%">
                    <label class="layui-form-label qbdms-label" title="审核员资格">审核员资格<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <select id="qualifications" lay-reqtext="审核员资格是必填项" lay-verify="required" name="qualification"></select>
                    </div>
                </div>
                <div style="width: 80%">
                    <label class="layui-form-label qbdms-label">地址</label>
                    <div class="layui-input-block qbdms-input">
                           <textarea name="address" placeholder="请输入" rows="2"
                                     autocomplete="off" class="layui-textarea" maxlength="50"></textarea>
                    </div>
                </div>
                <div style="width: 80%">
                    <label class="layui-form-label qbdms-label">备注</label>
                    <div class="layui-input-block qbdms-input">
                           <textarea name="remark" placeholder="请输入" rows="2"
                                     autocomplete="off" class="layui-textarea" maxlength="300"></textarea>
                    </div>
                </div>
            </div>

            <div class="layui-hide">
                <input type="text" name="id" placeholder="请输入" autocomplete="off"
                       class="layui-input textInput" maxlength="50" fieldname="id">
                <input type="text" name="worksid" placeholder="请输入工作单位id" autocomplete="off"
                       class="layui-input  textInput" maxlength="50" fieldname="worksid">
                <input type="text" name="transstatus" placeholder="请输入transstatus" autocomplete="off"
                       class="layui-input  textInput" maxlength="50" fieldname="transstatus">
                <input type="text" name="eventlever" placeholder="请输入eventlever" autocomplete="off"
                       class="layui-input  textInput" maxlength="50" fieldname="eventlever">
                <@dicSelect.dic  id="zlgl" search=true nodeKey="shyzgzl" />
                <@dicSelect.dic  id="zljy" search=true nodeKey="shyzgjy" />
                <@dicSelect.dic  id="shy" search=true nodeKey="shyzgsh" />
            </div>

            <div class="layui-form-item btnformItem">
                <p style="text-align: left;padding-left: 246px">
                    <span id="hideAndShow" style="">
                        <a lay-submit lay-filter="wQbdTeamExpertact" class="layui-btn privateSubmit qbdms-oneBtn" requrl="${ctx}/qbdms/wQbdTeamPeople/save">提交</a>
                    </span>
                    <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn   layui-btn-sm btn-save qbdms-oneBtnLine">取消</button>
                </p>
            </div>

        </form>
        </div>
    </div>
    </div>
    <script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
    <script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','setter', 'propsHandle', 'laydate', 'jquery','commonDialog', 'common','publicMethods','qbdmsForm','propsHandle'], function () {
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var form = layui.qbdmsForm;
        var common = layui.common;
        var publicMethods=layui.publicMethods;
        var dateTimeFiledLen = $(".dateTimeFiled");
        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'date'
                , trigger: 'click'
            });
        }


        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = '${ctx}/qbdms/wQbdTeamPeople/view/list';
        });

        form.verify({
            phoneNum: function (value,item) {
                // 如果值为空，不触发校验
                if (value && !new RegExp(/^1[3456789]\d{9}$/).test(value)) return common.verifyTitleAdd(item) + "手机号码有误";

            },
            servicePhone: function (value,item) {
                // 如果值为空，不触发校验
                // if (value && !new RegExp(/^$|(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/).test(value)) return "座机格式不正确";
                if (value && !new RegExp(/^([0-9]{1,6}[-]?)?([0][1-9][0-9]{1,2}[-]?)?[0-9]{6,8}$/).test(value)) return common.verifyTitleAdd(item) + "座机格式不正确";
            }
        });

        form.on('select(ry)', function (data) {
            setQualifications(data.value);
        });
        function setQualifications(key){
            if (key === "质量管理") {
                $("#qualifications").html($("#zlgl").html());
            } else if (key === "质量检验") {
                $("#qualifications").html($("#zljy").html());
            } else if (key === "审核员") {
                $("#qualifications").html($("#shy").html());
            }
            form.render('select');
        }

        var runId = "${runId}";
        if (runId == null || runId == '') {
            $("#hideAndShow").show();
        }
        var id = "${id}";
        if (id == null || id == '') {
            $("input[name='works']").val("${orgName}");
            $("input[name='worksid']").val("${code}");
        }

        $(function () {
            $("input[name='idcode']").on("input", function (e) {
                if (e.delegateTarget.value.length > 14) {
                    var birthday = "";
                    if(e.delegateTarget.value != null && e.delegateTarget.value !== ""){
                        if(e.delegateTarget.value.length === 15){
                            birthday = "19"+e.delegateTarget.value.substr(6,6);
                        } else if(e.delegateTarget.value.length === 18){
                            birthday = e.delegateTarget.value.substr(6,8);
                        }
                        birthday = birthday.replace(/(.{4})(.{2})/,"$1-$2-");
                    }
                    var date = birthday.split("-");
                    if(isdate(date[0],date[1],date[2])){
                        $("input[name='birthday']").val(birthday);
                    } else {
                        $("input[name='birthday']").val("");
                    }
                } else {
                    $("input[name='birthday']").val("");
                }
            });
        });

        // js判断年月日是否一个有效日期
        function isdate(intYear,intMonth,intDay){
            if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay)) return false;
            if(intMonth>12||intMonth<1) return false;
            if ( intDay<1||intDay>31)return false;
            if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30)) return false;
            if(intMonth==2){
                if(intDay>29) return false;
                if((((intYear%100==0)&&(intYear%400!=0))||(intYear%4!=0))&&(intDay>28))return false;
            }
            return true;
        }


        var common = layui.common;
        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name: 'wQbdTeamPeopleDataForm',
            idValue: "${id}",
            primary: "id",
            beforeSubmitFun: function (data) {

            },
            getCallback: function (data) {
                setQualifications(data.data.peopletype);
            },
            updateCallback: function (data) {
                if (common.filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = '${ctx}/qbdms/wQbdTeamPeople/view/list';
                    });
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                }
                return false;
            }
        });
    });
</script>
</body>
</html>